package com.ruoyi.system.service.other;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.RecordId;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.connection.stream.StringRecord;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;


@Service
public class MessageProducerService {

    @Resource
    private StringRedisTemplate stringRedisTemplate;


    public Long sendMeassage(String message) {
        // 创建消息记录, 以及指定stream
        StringRecord stringRecord = StreamRecords.string(Collections.singletonMap("name", message)).withStreamKey("mystream");
        RecordId recordId = this.stringRedisTemplate.opsForStream().add(stringRecord);

        return null;
    }

}